Socket
Socket
Sign inDemoInstall

har-validator

Package Overview
Dependencies
16
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    har-validator

Extremely fast HTTP Archive (HAR) validator using JSON Schema


Version published
Maintainers
1
Created

Package description

What is har-validator?

The har-validator npm package is a library designed to validate HTTP Archive (HAR) files. HAR files are JSON-formatted archives that track all the logging of a web browser's interaction with a site. This package ensures that HAR files adhere to the specification and structure expected, making it useful for developers working with web performance and debugging, API testing, and network monitoring.

What are har-validator's main functionalities?

HAR file validation

This feature allows developers to validate HAR files against the HAR format specification. The code sample demonstrates how to use the har-validator package to validate a HAR file. If the file is valid, it logs a success message; otherwise, it catches and logs the validation error.

const HARValidator = require('har-validator');

async function validateHAR(harData) {
  try {
    const valid = await HARValidator.har(harData);
    console.log('HAR is valid:', valid);
  } catch (err) {
    console.error('HAR validation error:', err.message);
  }
}

Other packages similar to har-validator

Readme

Source

HAR Validator version License

Extremely fast HTTP Archive (HAR) validator using JSON Schema.

Build Status Downloads Code Climate Coverage Status Dependencies

Install

# to use in cli
npm install --global har-validator

# to use as a module
npm install --save har-validator

Usage


  Usage: har-validator [options] <files ...>

  Options:

    -h, --help           output usage information
    -V, --version        output the version number
    -s, --schema [name]  validate schema name (log, request, response, etc ...)

Example
har-validator har.json

har-validator --schema request request.json

API

Validate(data [, callback])

Returns true or false.

  • data: Object (Required) a full HAR object

  • callback: Function gets two arguments (err, valid)

var HAR = require('./har.json');
var validate = require('har-validator');

validate(HAR, function (e, valid) {
  if (e) console.log(e.errors)

  if (valid) console.log('horray!');
});

Validate.log(data [, callback])

Returns true or false.

  • data: Object (Required) a log object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.log(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.cache(data [, callback])

Returns true or false.

  • data: Object (Required) a cache object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.cache(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.cacheEntry(data [, callback])

Returns true or false.

var validate = require('har-validator');

validate.cacheEntry(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.content(data [, callback])

Returns true or false.

  • data: Object (Required) a content object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.content(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.cookie(data [, callback])

Returns true or false.

  • data: Object (Required) a cookie object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.cookie(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.creator(data [, callback])

Returns true or false.

  • data: Object (Required) a creator object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.creator(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.entry(data [, callback])

Returns true or false.

  • data: Object (Required) an entry object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.entry(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.log(data [, callback])

alias of Validate(data [, callback])

Validate.page(data [, callback])

Returns true or false.

  • data: Object (Required) a page object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.page(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.pageTimings(data [, callback])

Returns true or false.

  • data: Object (Required) a pageTimings object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.pageTimings(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.postData(data [, callback])

Returns true or false.

  • data: Object (Required) a postData object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.postData(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.record(data [, callback])

Returns true or false.

  • data: Object (Required) a record object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.record(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.request(data [, callback])

Returns true or false.

  • data: Object (Required) a request object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.request(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.response(data [, callback])

Returns true or false.

  • data: Object (Required) a response object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.cacheEntry(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Validate.timings(data [, callback])

Returns true or false.

  • data: Object (Required) a timings object

  • callback: Function gets two arguments (err, valid)

var validate = require('har-validator');

validate.timings(data, function (e, valid) {
  if (e) console.log(e.errors)
});

Support

Donations are welcome to help support the continuous development of this project.

Gratipay PayPal Flattr Bitcoin

License

ISC License © Ahmad Nassri

Keywords

FAQs

Last updated on 22 Jun 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc